<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <g:set var="entityName" value="${message(code: 'estate.label', default: 'Estate')}" />
    <title>催收列表</title>
    <style>
    .contact-stat{
        padding: 8px 0px;
        text-align: center;
    }
    .contact-stat span{
        font-size: 13px;
        color: #88898c;
        margin-bottom: 10px;
    }
    .contact-stat strong{
        font-size: 13px;
        word-wrap: break-word;
    }
    .nav-tabs{
        border-bottom: none;
    }
    .hpanel > .panel-footer, .hpanel > .panel-section{
        background: #f9f9f9;
    }

    .newFontSize{
        font-size: 12px;
    }
    table>tbody>tr>td, table>tbody>tr>th,.table>tfoot>tr>td, table>tfoot>tr>th, table>thead>tr>td, table>thead>tr>th{
        padding: 8px;
        line-height: 1.42857143;
    }

    </style>
</head>
<body class="fixed-navbar fixed-sidebar">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span>催收列表</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                催收列表
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="overdueCollectionIndex" class="form-horizontal" role="form" id="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit" onclick="text()"><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
                <div class="panel-body seach-group" id="bug1">
                    <div class="row">
                        <input type="hidden" name="flag" value="${params.flag}">
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">借款人姓名</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="fullName" id="fullName" value="${params?.fullName}" placeholder="请输入借款人姓名">
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">证件类型</label>
                            <div class="col-sm-9 input-group" style="display: flex;justify-content: center">
                                <g:select class="form-control" name="identityType" id="identityType"
                                          optionKey="id" optionValue="name"
                                          from="${com.cindata.dictionary.ContactIdentityType.list()}"
                                          value="${params?.identityType}"
                                          noSelection="${['': '请选择证件类型']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">证件号码</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="idNumber" id="idNumber" value="${params?.idNumber}" placeholder="请输入证件号码">
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">手机号</label>
                            <div class="col-sm-9 input-group">
                                <input type="text" class="form-control" name="cellphone" id="cellphone" value="${params?.cellphone}" placeholder="请输入借款人手机号">
                            </div>
                        </div>
                </div>

                <div class="row">
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">处置阶段</label>
                        <div class="col-sm-9 input-group" style="display: flex;justify-content: center">
                            <g:select class="form-control" name="stage" id="stage" from="${com.cindata.dictionary.RiskWarningStage.list()}" value="${params?.stage}" optionKey="id" optionValue="name"
                                noSelection="${['': '请选择处置阶段']}"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">处置部门</label>
                        <div class="col-sm-9 input-group" style="display: flex;justify-content: center">
                            <g:select class="form-control" name="disposalDepartment" id="disposalDepartment" from="${com.cindata.Department.list()}" value="${params?.disposalDepartment}" optionKey="id" optionValue="name"
                                noSelection="${['': '请选择处置措施']}"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label  class="col-sm-3 control-label">违约期数</label>
                        <div class="col-sm-7  input-group">
                            <input type="text" class=" form-control " placeholder="请输入下限" id="defaultStart" maxlength="6" value="${params?.defaultStart}" name="defaultStart" />
                            <span class="input-group-addon">至</span>
                            <input type="text" class="form-control " placeholder="请输入上限" maxlength="6" id="defaultEnd"  value="${params?.defaultEnd}" name="defaultEnd" />
                        </div>
                        <div class="col-sm-2 p-t-xss">
                            次数
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label  class="col-sm-3 control-label">逾期期数</label>
                        <div class="col-sm-7  input-group">
                            <input type="text" class=" form-control " placeholder="请输入下限" id="overdueStart" maxlength="6" value="${params?.overdueStart}" name="overdueStart" />
                            <span class="input-group-addon">至</span>
                            <input type="text" class="form-control " placeholder="请输入上限"  id="overdueEnd"  maxlength="6" value="${params?.overdueEnd}" name="overdueEnd" />
                        </div>
                        <div class="col-sm-2 p-t-xss">
                            次数
                        </div>
                    </div>
                </div>
            </div>
        </g:form>
    </div>
    </div>
    <div class="row" id="contactList">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部催收列表（个人）
            </div>
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center" id="contactTable">
                        <thead>
                        <tr>
                            <g:sortableColumn property="serialNumber" title="贷款编号"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="fullName" title="借款人姓名"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="cellphone" title="手机号"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="sourceAddress" title="地址"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="loansBalance" title="贷款余额"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="loansAmount" title="贷款总额"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="buildingType" title="抵押物类型"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="curRepaymentMode" title="还款方式"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="status" title="贷款状态"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="creditBalance" title="违约期数"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="curOverdueDuration" title="逾期期数"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="curOverdueDuration" title="逾期天数"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="riskWarningLevel" title="风险等级"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="type" title="预警类型"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="workflow" title="工作流"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="stage" title="处置阶段"  class="text-center" params="${params}"/>
                            <!-- <g:sortableColumn property="disposalDepartment" title="处置部门"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="user" title="处置负责人"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="description" title="处置说明"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="startTime" title="计划开始时间"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="endTime" title="计划完成时间"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="actualStartTime" title="实际开始时间"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="actualEndTime" title="实际完成时间"  class="text-center" params="${params}"/> -->
                            <!-- <th class="text-center sortable" style="color: #34495e;">操作项</th> -->
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${riskWarningList}">
                            <tr>
                                <td class="nameFormat"><g:link style="color: #3498DB" action="contactOverdueWarningShow" id="${it?.id}" params="[ targetUri: 'contactOverdueWarning']">${it?.mortgage?.serialNumber ? it?.mortgage?.serialNumber : '-'}</g:link></td>
                                <td class="nameFormat">${it?.mortgage?.mortgageContact?.fullName}</td>
                                <td class="cellphoneFormat">${it?.mortgage?.mortgageContact?.cellphone ? it?.mortgage?.mortgageContact?.cellphone : '-'}</td>
                                <td>${com.cindata.MortgageCollateral.findByMortgage(it?.mortgage)?.collateral?.estate?.sourceAddress}</td>
                                <td>${it?.mortgage?.loansBalance ? it?.mortgage?.loansBalance : '-'}</td>
                                <td>${it?.mortgage?.loansAmount ? it?.mortgage?.loansAmount : '-'}</td>
                                <td>${com.cindata.MortgageCollateral.findByMortgage(it?.mortgage)?.collateral?.estate?.buildingType?.name}  </td>
                                <td>${it?.mortgage?.curRepaymentMode?.name ? it?.mortgage?.curRepaymentMode?.name : '-'}</td>
                                <td>${it?.mortgage?.mortgageStatus?.name ? it?.mortgage?.mortgageStatus?.name : '-'}</td>
                                <td>${it?.mortgage?.curDefaultingDuration ? it?.mortgage?.curDefaultingDuration : '-'}</td>
                                <td>${it?.mortgage?.curOverdueDuration ? it?.mortgage?.curOverdueDuration : '-'}</td>
                                <td>${it?.mortgage?.curOverdueDuration ? it?.mortgage?.curOverdueDuration * 30 + ' 天': '-'}</td>
                                <td>${it?.mortgage?.riskWarningLevel ? it?.mortgage?.riskWarningLevel?.name : '-'}</td>
                                <td>${it?.type?.name}</td>
                                <td>${it?.workflow?.name}</td>
                                <td>${it?.stage?.name}</td>
                                <!-- <td>${it?.disposalDepartment?.name}</td>
                                <td>${it?.disposalUser?.fullName}</td>
                                <td>${it?.description}</td>
                                <td><g:formatDate date="${it?.startTime}" format="yyyy-MM-dd"></g:formatDate></td>
                                <td><g:formatDate date="${it?.endTime}" format="yyyy-MM-dd"></g:formatDate></td>
                                <td><g:formatDate date="${it?.actualStartTime}" format="yyyy-MM-dd"></g:formatDate></td>
                                <td><g:formatDate date="${it?.actualEndTime}" format="yyyy-MM-dd"></g:formatDate></td> -->
                                <!-- <g:if test="${it?.stage?.code == '10' && params['flag'] != 'true'}">
                                    <td class="text-center">
                                        <button class="btn btn-xs btn-outline btn-success disposal" dataId="${it?.id}" data-toggle="modal" data-target="#myModal7">分发</button>
                                    </td>
                                </g:if>
                                <g:elseif test="${it?.stage?.code == '13' && params['flag'] != 'true'}">
                                    <td class="text-center">
                                        <g:link class="btn btn-xs btn-outline btn-success" action="mortgageWarningDisposalAsign" id="${it?.id}">安排</g:link>
                                    </td>
                                </g:elseif>
                                <g:else>
                                    <td class="text-center">
                                        <g:link class="btn btn-xs btn-outline btn-success" action="contactOverdueWarningShow" id="${it?.id}" params="[targetUri: 'overdueCollectionIndex']">详情</g:link>
                                    </td>
                                </g:else> -->
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate action="overdueCollectionIndex" total="${riskWarningCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade hmodal-success" id="myModal7" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <g:form action="mortgageWarningDisposalSave1" method="post" class="disposqlForm">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">作业部门</h4>
                </div>
                <div class="modal-body modalHeight">
                    <div class="form-horizontal">

                        <input type="hidden" id="riskWarning" name="riskWarning" value="${riskWarning?.id}"/>

                        <div class="form-group" style="margin-bottom: 0;">
                            <label class="col-md-2 control-label is-required" >作业部门</label>
                            <div class="col-md-6 " style="display: flex;align-items: center;">
                                <g:select class="form-control" name="department" id="department" from="${com.cindata.Department.list()}" optionKey="id" optionValue="name" value="${riskWarning?.department?.id}" noSelection="${['': '请选择作业部门']}"/>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-success disposqlBtn">
                        <span>开始处置</span>
                    </button>
                    <button type="reset" class="btn btn-danger" data-dismiss="modal">
                        <span>取消处置</span>
                    </button>
                </div>
            </div>
        </g:form>
    </div>
</div>

<script>

    $(".disposal").click(function() {
        var riskWarning = $(this).attr("dataId").trim();
        $("#riskWarning").val(riskWarning)
    })

    // 确认失败
    $(document).delegate(".disposqlBtn", "click",
        function() {
            var riskWarning = $("#riskWarning").val();
            var department = $("#department").val();
            if (!department) 
            {
                toastr.error('请选择作业部门！');
                return
            }
            swal({
                title: "是否确认提交吗?",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#3aa9dd",
                cancelButtonText: "取消",
                confirmButtonText: "确认",
                closeOnConfirm: false,
                closeOnCancel: true
            },
            function(isConfirm) {
                if (isConfirm) {
                    $(".disposqlForm").submit();
                    swal("提交成功！", "", "success");
                }
            });
        }
    );

    //条件重置
    $("#resetBtn").click(function () {
        $("#fullName").val("");
        $("#s2id_identityType span:first").html("请选择证件类型");
        $("#identityType").val("");
        $("#idNumber").val("");
        $("#cellphone").val("");
        $("#s2id_disposalDepartment span:first").html("请选择处置部门");
        $("#disposalDepartment").val("");
        $("#s2id_stage span:first").html("请选择处置阶段");
        $("#stage").val("");
        $("#defaultStart").val("");
        $("#defaultEnd").val("");
        $("#overdueStart").val("");
        $("#overdueEnd").val("");
    });
</script>

</body>
</html>
